<head>

<script type="text/javascript"
	src=" https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
<script type="text/javascript"
	src=" https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.12/jquery-ui.min.js"></script>
<script src="../../../public/javascript/jquery.js"
	type="text/javascript"></script>
<script src="../../../public/javascript/scripts.js"
	type="text/javascript"></script>

<script type="text/javascript">
	function getOrganizers(entityID) {

		document.getElementById("organizers").innerHTML = "";

		$
				.getJSON(
						'@{Application.getOrganizersEntity()}',
						{
							'entityID' : document.getElementById("entityID").value
						},
						function(data) {

							s = data.res.split("*");

							var total = "<p><label>choose organizer to restrict</label><select id=\"org\">"
							for ( var i = 1; i < s.length; i = i + 1) {
								if (s[i] != "") {
									total += "<option selected value="+i+">"
											+ s[i] + "</option>";
								}
							}
							total += "</select></p>";
							document.getElementById("organizers").innerHTML = total;
						});

	}
	function resOrganizers(entityID, leadID) {

		var index = document.getElementById("org").selectedIndex
		var organizerName = document.getElementById("org").options[index].text
		var label="";
		var string ="";
		var t="";
		$.getJSON('@{Application.resOrganizersEntity()}', {
			'entityID' : document.getElementById("entityID").value,
			'organizerName' : organizerName
		}, function(data) {
        s=data.res.split("%^%");
		sfirst=s[0];
		spit=sfirst.split("&");
		
		if(spit[0].length>11)
	    {
		  string=spit[0]+"<BR/>";
		}
		if(spit[1].length>11)
		{
			string+="  "+spit[1];
		}
		spitt=s[1].split("&");
		if(spitt[0].length>11)
	    {
		  t=spitt[0]+"<BR/>";
		}
		if(spitt[1].length>11)
		{
			t+="  "+spitt[1];
		}
		if(string.length>0)
		{
			 label+="<label>"+organizerName+" is now restricted to this entity by removing him from organizing the following :<BR/>"+string+"</label><BR/>";
		}
        
        if(t.length>0)
        {
               label+="<BR/><label>"+organizerName+" can not be removed from organizing the following because last organizer on Topic or Entity :<BR/>"+t+"</label>";
       	}
        document.getElementById("label").innerHTML=	label;
		});

	}

</script>

</head>
<body onload="javascript:getOrganizers()">
	<div>
		<form name="input" action="#" method="get">

			<a href='#' onclick="javascript:resOrganizers()">Restrict
				Organizer</a>
		</form>
	</div>
	<div>
		<div id="organizers"></div>
		<div id="test"></div>
		<div id="test1"></div>
	</div>
	<div id="label"></div>
	<input id="leadID" type="hidden" value="${leadID}" />
	<input id="topicID" type="hidden" value="${topicID}" />
	<input id="entityID" type="hidden" value="${entityID}">
	<input id="eID" type="hidden" value="${eID}">
</body>